home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / comm / net / tf02.lha / TinyFugue / tf-lib / spedwalk.tf < prev    next >
Text File  |  1995-08-12  |  2KB  |  54 lines

  1. ;;;; Speedwalk
  2. ;;;; "/speedwalk" toggles speedwalking.  With speedwalking enabled, you can
  3. ;;;; type multiple directions on a single line, similar to tintin.  Any line
  4. ;;;; containing only numbers and the letters "n", "s", "e", "w", "u", and
  5. ;;;; "d" are interpreted by speedwalk; other lines are left alone (of course,
  6. ;;;; to guarantee that lines don't get interpreted, you should turn speedwalk
  7. ;;;; off).  Each letter is sent individually; if it is preceeded by a number,
  8. ;;;; it will be repeated that many times.  For example, with speedwalk
  9. ;;;; enabled, typing "ne3ses" will send "n", "e", "s", "s", "s", "e", "s".
  10.  
  11.  
  12. /~loaded speedwalk.tf
  13.  
  14. /eval \
  15.     /def -i speedwalk = \
  16.         /if /ismacro ~speedwalk%%; /then \
  17.             /echo %%% Speedwalk disabled.%%;\
  18.             /undef ~speedwalk%%;\
  19.         /else \
  20.             /echo %%% Speedwalk enabled.%%;\
  21. ;           /def -iFp%{maxpri} -hsend ~speedwalk = \
  22.             /def -iFp%{maxpri} -mregexp -h'send ^[nsewud0-9]+$$$' ~speedwalk = \
  23.                 /~do_speedwalk %%%*%%;\
  24.         /endif
  25.  
  26. /def -i ~do_speedwalk = \
  27.     /let args=%*%;\
  28.     /let string=%;\
  29.     /let count=%;\
  30.     /let c=%;\
  31.     /let i=-1%;\
  32.     /while ( (c:=substr(args, (i:=i+1), 1)) !~ "" ) \
  33.         /if ( c =/ "[0-9]" ) \
  34.             /test count:= strcat(count, c)%;\
  35.         /elseif ( regmatch("[nsewud]", c) ) \
  36.             /if ( string !~ "" ) /send - %{string}%; /endif%;\
  37.             /let string=%;\
  38.             /for j 1 %{count-1} /~do_speedwalk_aux %{c}%;\
  39.             /let count=%;\
  40.         /else \
  41.             /test string:= strcat(string, count, c)%;\
  42.             /let count=%;\
  43.         /endif%;\
  44.     /done%;\
  45.     /let string=%{string}%{count}%;\
  46.     /if ( string !~ "" ) /send - %{string}%; /endif
  47.  
  48. /def -i ~do_speedwalk_aux = \
  49. ;   _map_hook may be defined if map.tf was loaded.
  50.     /if /ismacro _map_hook%; /then \
  51.         /_map_hook %*%;\
  52.     /endif%;\
  53.     /send - %*
  54.